package com.me.brainlessbirds.actors.obstacles;

import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.me.brainlessbirds.actors.Unit;
import com.me.brainlessbirds.actors.interfaces.SurvivorCollidable;
import com.me.brainlessbirds.actors.interfaces.ZombieCollidable;
import com.me.brainlessbirds.actors.survivors.units.Civilian;
import com.me.brainlessbirds.actors.survivors.units.Engineer;
import com.me.brainlessbirds.actors.survivors.units.Flamethrower;
import com.me.brainlessbirds.actors.survivors.units.Soldier;
import com.me.brainlessbirds.actors.zombies.units.Brainless;
import com.me.brainlessbirds.actors.zombies.units.Smoothie;
import com.me.brainlessbirds.actors.zombies.units.Undertaker;
import com.me.brainlessbirds.actors.zombies.units.Winehouse;
import com.me.brainlessbirds.screens.GameScreen;

public abstract class Obstacle extends Unit implements SurvivorCollidable, ZombieCollidable
{
	public enum ObstacleType
	{
		BARRICADE, BUMPER, MINE;
	}

	/*
	 * Obstacle's Statistics
	 */
	protected ObstacleType	type			= null;
	protected float			recharge		= 0f;
	protected boolean		active			= true;
	protected boolean		destructible	= true;
	protected boolean		down			= false;
	protected TextureRegion	rgnDown			= new TextureRegion();

	@Override
	public void draw(SpriteBatch batch, float parentAlpha)
	{
		batch.setColor(this.getColor());
		if (this.down)
		{
			batch.draw(rgnDown, getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(), getScaleX(), getScaleY(), getRotation());
		}
		else
		{
			batch.draw(rgn, getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(), getScaleX(), getScaleY(), getRotation());
		}
	}

	public void hit(float damage)
	{
		this.life -= damage;
	}

	public float getLife()
	{
		return this.life;
	}

	public void destroy()
	{
		if (this.down)
		{
			return;
		}
		this.down = true;
		GameScreen.get().createParticleEffect(Obstacle.this.getX() + Obstacle.this.getWidth() / 2, Obstacle.this.getY() + Obstacle.this.getHeight() / 2);
		/*
		 * Task callbackTask = new Task()
		 * {
		 * 
		 * @Override
		 * public void run()
		 * {
		 * GameScreen.get().createParticleEffect(Obstacle.this.getX() + Obstacle.this.getWidth() / 2, Obstacle.this.getY() + Obstacle.this.getHeight() / 2);
		 * Obstacle.this.remove();
		 * }
		 * };
		 * 
		 * super.destroy(callbackTask);
		 */
	}

	public void start(Stage stage, float x, float y)
	{
		setPosition(x, y - (getHeight() / 2));
	}

	public boolean isDown()
	{
		return this.down;
	}

	public void repare()
	{
		this.down = false;
	}

	// Zombies

	@Override
	public void OnHitByBrainless(Brainless _b)
	{
	}

	@Override
	public void OnHitBySmoothie(Smoothie _s)
	{
		// TODO Auto-generated method stub
	}

	@Override
	public void OnHitByUndertaker(Undertaker _u)
	{
		// TODO Auto-generated method stub

	}

	@Override
	public void OnHitByWinehouse(Winehouse _w)
	{
		// TODO Auto-generated method stub

	}

	//Survivors

	@Override
	public void OnHitByCivilian(Civilian _c)
	{
		// TODO Auto-generated method stub

	}

	@Override
	public void OnHitByEngineer(Engineer ec)
	{
		// TODO Auto-generated method stub

	}

	@Override
	public void OnHitByFlamethrower(Flamethrower _f)
	{
		// TODO Auto-generated method stub

	}

	@Override
	public void OnHitBySoldier(Soldier _s)
	{
		// TODO Auto-generated method stub

	}
}
